import {ADD_SHOP,ADD_COUNTER,ADD_PRODUCT,GET_SHOP,KIND_SHOP} from "./mutation-type";
export default {
        [ADD_PRODUCT](context,payload){
            //查找之前是否有该商品
           let oldProduct = context.state.shopInfo.find(item => item.iid === payload.iid);
           //判断oldproduct
            if (oldProduct){
                context.commit(ADD_COUNTER,oldProduct)
            }else{
                payload.count = 1;
                payload.checked = true;//商品默认为选中转态
                context.commit(ADD_SHOP,payload)
            }
        },
        [GET_SHOP](context,payload){
            context.commit(KIND_SHOP,payload)
        }
};